﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Buccontrols;
using PluginInterface;

namespace Buccaneer
{
    public partial class AddressBarControl : PluginControl
    {
        private NavigateAction refreshAction;

        public AddressBarControl()
        {
            InitializeComponent();

            this.refreshAction = new NavigateAction(this);
            MainProgram.Plugins.RegisterAction(refreshAction);
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                MainProgram.Plugins.Act("navigate", new string[] 
                {
                    this.tbx_address.Text
                });
            }
        }

        private void AddressBarControl_Load(object sender, EventArgs e)
        {
            //this.tbx_address.MouseDown += new MouseEventHandler(PluginForm_MouseDown);
        }
    }

    public class NavigateAction : PluginAction
    {
        AddressBarControl ac;

        public NavigateAction(AddressBarControl ac)
        {
            base.name = "navigate";
            base.func = new ActionFunction(this.Navigate);
            base.plugin = plugin;
            base.pars.Add("path", "the path to put in the addressbar control");
            this.ac = ac;
        }

        public void Navigate(string[] args)
        {
            this.ac.tbx_address.Text = args[0];
        }
    }
}
